package com.zhao.dota.bo;

import com.zhao.dota.model.Permission;
import lombok.Data;
import org.springframework.security.core.CredentialsContainer;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

@Data
public class AuthenticateUser implements UserDetails, CredentialsContainer, Serializable {

    private Integer id;

    private String username;

    private String password;

    private Collection<? extends GrantedAuthority> authorities;

    private boolean enabled;

    private String openId;

    private String unionId;

    private String avatar;

    private String nickName;

    private String phone;

    private int gender;

    private Boolean canChangeUsername;

    private boolean steamAuthorized;

    private List<Permission> menus;

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return enabled;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }

    @Override
    public void eraseCredentials() {
        this.password = null;
    }
}
